RemoveDuplicatesInPlace Generic Method

Wintellect PowerCollections

Collapse imageExpand ImageCollapseAll imageExpandAll imageDropDown imageDropDownHover imageCopy imageCopyHover image
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Remove consecutive "equal" items from a list or array. In each run of consecutive equal items in the list, all items after the first item in the run are removed. The replacement is done in-place, changing the list. The passed BinaryPredicate is used to determine if two items are "equal".

Namespace: Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax

C#
public static void RemoveDuplicatesInPlace<T>(
	IList<T> list,
	BinaryPredicate<T> predicate
)
Visual Basic (Declaration)
Public Shared Sub RemoveDuplicatesInPlace(Of T) ( _
	list As IList(Of T), _
	predicate As BinaryPredicate(Of T) _
)
Visual C++
public:
generic<typename T>
static void RemoveDuplicatesInPlace (
	IList<T>^ list, 
	BinaryPredicate<T>^ predicate
)

Parameters

list
IList<(Of <T>)>
The list or array to process.
predicate
BinaryPredicate<(Of <T>)>
The BinaryPredicate used to compare items for "equality".

Type Parameters

T

Remarks

Since an arbitrary BinaryPredicate is passed to this function, what is being tested for need not be true equality.

Although arrays cast to IList<T> are normally read-only, this method will work correctly and modify an array passed as list.

See Also